package Auxiliary;

import java.util.Vector;
import javax.swing.JOptionPane;
import Store.Row;

public class Sequence_Row
{
	private Vector<Row> v;
	
	public Sequence_Row()
	{
		this.v = new Vector<Row>();
	}
	
	public void add(Row r)
	{
		v.add(r);
	}
	
	public void delete(Row r)
	{
		if(v.contains(r))
			v.remove(r);
		
		else
		{
			JOptionPane.showMessageDialog(null,
					"Elemento non presente", "Error",
					JOptionPane.WARNING_MESSAGE);
			
		}
	}
	
	public Row get(int i)
	{
		return v.elementAt(i);
		
	}
	
	public Vector<Row> getAll()
	{
		return v;
	}
	
	
	public int size()
	{
		return v.size();
		
	}

	public Row find(Row aRow) 
	{
		for (Row r : v)
			if(r.equals(aRow))
				return r;
		return null;
	}
	
	public Row find(String name)
	{
		for (Row r : v)
			if (r.getName()==name)
				return r;
		return null;
	}
}